#pragma once
#include "uv.h"

class UvServer
{
public:
	UvServer();
	virtual ~UvServer();
	void SetPort(int nPort);
	int  GetPort() const;
	bool Start();
protected:
	virtual void OnConnect(uv_tcp_t* client) = 0;
	static void ThreadProc(void* arg);
	virtual void ThreadFunc();
	static void OnConnect(uv_stream_t* server, int status);
	static void OnClose(uv_handle_t* handle);
protected:
	int			m_nPort;
	uv_tcp_t	m_Server;
	uv_loop_t*	m_pLoop;
};
